Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Add support for comments containing Unicode #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DevynCJohnson
Copy link

When using Flake8 (with Flake8-Mypy) on Python scripts containing comments with Unicode comments, Flake8 crashes with a UnicodeEncodeError. The suggested code in my commit appears to resolve the issue without side-effects.

When using Flake8 (with Flake8-Mypy) on Python scripts containing comments with Unicode comments, Flake8 crashes with a UnicodeEncodeError. The suggested code in my commit appears to resolve the issue without side-effects.
@ambv
Copy link
Owner

ambv commented May 20, 2018

I don't understand how the current behavior (which sets encoding to 'utf8' in the NamedTemporaryFile) is any worse than your suggested encoding of every line to utf8 and writing in binary.

) as f:
self.filename = f.name
for line in self.lines:
f.write(line.encode(r'utf8'))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line.encode() here might fail exactly like the f.write() line above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants